﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HZ.Supervise.Web.Meet
{
    public partial class AddPxContent : BasePage
    {
        IBLL.IBLL_ProcureCatalog ihc = new HZ.Supervise.BLL.BLL_ProcureCatalog();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request["mid"] == null)
                {
                    Response.Redirect("MeetList.aspx");
                }
                else
                {
                    Bind();
                }
            }
        }
        private void Bind()
        {
            DataTable dt = ihc.GetPxContent(CurrentAccount.GetUser().Org.OrgID, Request["mid"].ToString());
            if (dt.Rows.Count > 0)
            {
                lbming.Text = "查看培训内容需求";
                txtcontent.Text = dt.Rows[0]["Content"].ToString();
            }
            else
            {
                lbming.Text = "填写培训内容需求";
            }

            if (BMGS(Request["mid"].ToString()) == 1)//报名截止
            {
                btnadd.Visible = false;
            }
        }
        //判断报名是否过时 1过时 0未过时
        private int BMGS(string mid)
        {
            return ihc.IsBmGuoShi(mid);
        }
        protected void btnadd_Click(object sender, EventArgs e)
        {
            if (BMGS(Request["mid"].ToString()) == 1)//报名截止
            {
                HZ.Web.WebUtil.Alert("会议报名时间已截止，操作失败！", this);
                return;
            }
            if (txtcontent.Text.Trim().Length > 200)
            {
                HZ.Web.WebUtil.Alert("需求请控制在200字以内");
                return;
            }
            Model.User u = CurrentAccount.GetUser();
            Model.MeetPxContent mt = new Model.MeetPxContent();
            mt.MID = Request["mid"].ToString();
            mt.JID = u.Org.OrgID;
            mt.JName = u.UserName;
            mt.ArID = u.Org.Area.AreaID;
            mt.Content = txtcontent.Text.Trim();
            if (ihc.SetPxContent(mt) == 1)
            {
                HZ.Web.WebUtil.Alert("保存成功");
            }
            else
            {
                HZ.Web.WebUtil.Alert("保存失败");
            }
            Bind();
        }

        protected void btnret_Click(object sender, EventArgs e)
        {
            Response.Redirect("CHRYList.aspx?mid=" + Request["mid"].ToString());
        }
    }
}